//引入App，仓库，pinia，写函数，如果不存在按钮，就找其父元素，将其删掉
import type { App } from "vue";
import { useUserInfoStore } from "@/stores/userInfo";
import pinia from "@/stores/index";

export default function hasBtnPermission(app: App) {
  // app.directive('has',(el,binding)=>{
  //   if(useUserInfoStore(pinia).userInfo.buttons.indexOf(binding.value) === -1){
  //     el.parentNode.removeChild(el)
  //   }
  // })
  // 只要挂载时需要
  app.directive("has", {
    mounted(el, binding) {
      if (
        useUserInfoStore(pinia).userInfo.buttons.indexOf(binding.value) === -1
      ) {
        el.parentNode.removeChild(el);
      }
    },
  });
}
